# 1.建立连接
from minio import Minio

minioClient = Minio(
    endpoint='120.53.236.89:6001',  # 文件服务地址
    access_key='admin',  # 用户名
    secret_key='110120xl',  # 密钥
    secure=False  # 设为True代表启用HTTPS
)

# 2.设置永久可下载
# a. 桶名
bucket_name = 'mond'  # 修改为自己已创建的桶名

# b.通过桶权限设置方法，修改时间期限限制。
policy = '{"Version":"2012-10-17","Statement":[{"Effect":"Allow","Principal":{"AWS":["*"]}, "Action": ["s3:GetBucketLocation", "s3:ListBucket"], "Resource":["arn:aws:s3:::%s"]}, {"Effect": "Allow", "Principal": {"AWS": ["*"]}, "Action":["s3:GetObject"], "Resource": ["arn:aws:s3:::%s/*"]}]}' % (bucket_name, bucket_name)
minioClient.set_bucket_policy(bucket_name=bucket_name, policy=policy)
